package com.xq.springboot.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.xq.springboot.pojo.Permission;
import com.xq.springboot.mapper.PermissionMapper;
import com.xq.springboot.service.PermissionService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xq
 * @date 2021/4/18 21:58
 * @version 1.0
 * @description 权限业务服务层接口实现层
 */
@Service
public class PermissionServiceImpl implements PermissionService{

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public List<String> getPermissionByUserId(Integer userId) {
        // 根据用户ID查询权限集合
        List<Permission> permissionByUserId = this.permissionMapper.getPermissionByUserId(userId);
        // 保存权限编码的容器
        List<String> permissionCodeList = new ArrayList<>();
        permissionByUserId.stream().forEach(i -> {
            permissionCodeList.add(i.getPermissionCode());
        });
        return permissionCodeList;
    }
}
